#ifndef _FR_IP_BLOCK_H_
#define _FR_IP_BLOCK_H_

typedef (unsigned int) uint32;
typedef (void*) frPosition;

class frIpV4Block
{
public:
	frIpV4Block()
	{
	}
	~frIpV4Block()
	{
	}
	void addIpBlock(const uint32 begin, const uint32 end)
	{
	
	
	}
	
	void delIpBlock(const uint32 begin, const uint32 end)
	{
	
	
	}
	
	bool findIp(const uint32 ip)
	{
	
	}
	
	bool findIp(const frString &ip)
	{
	
	}
	
	frPosition getIpBlockHead()
	{
		return (frPosition) m_head;
	}
	
	frPosition findNextIpBlock(uint32 &begin, uint32 &end)
	{
		FR_IPBLOCK *block = (FR_IPBLOCK *)frPosition;
		begin = block->begin;
		end = block->end;
		return (frPosition)block->next;
	}
	
	static uint32 ipStrToUint32(const frString &s)
	{
		
	}
	
	static frString ipUint32ToStr(const uint32 u)
	{
	
	}
	
	static uint32 ipStrToUint32(const char *s)
	{
		uint32 i[4];
		sscanf(s, "%u.%u.%u.%u", &i[0], &i[1], &i[2], &i[3]);
		i[0] = i[0] << 24;
		i[1] = i[1] << 16;
		i[2] = i[2] << 8;
		return i[0] | i[1] | i[2] | i[3];
	}
	
	static char *ipUint32ToStr(const uint32 u)
	{
		char buf[16];
		uint8 *i = u;
		sprintf(buf,"%u.%u.%u.%u", i[0], i[1], i[2], i[3]);
		return buf;
	}

private:
	struct FR_IPBLOCK
	{
		uint32 begin;
		uint32 end;
		FR_IPBLOCK *next;
	};
	
	FR_IPBLOCK *m_head;
};

#endif //! _FR_IP_BLOCK_H_